<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="assetMenu" />
<meta name="nav" content="1" />
<meta name="acc" content="0-0-1" />
<style type="text/css">
</style>
<title>车辆登记</title>
<!--  通用情况下 不引入 js css  表单验证  js 放置到页面中 -->
<script>
	$(document)
			.ready(
					function() {
						$("input[name='productionDate']")
								.addClass("Wate")
								.bind(
										"click",
										function() {
											WdatePicker({
												skin : 'whyGreen',
												minDate : '1900-10-01',
												maxDate : '#F{$dp.$D(\'buyNewDate\')||\'%y-%M-%d\'}',
												dateFmt : 'yyyy-MM-dd'
											});
										});
						$("input[name='buyDate']").addClass("Wate").bind(
								"click", function() {
									WdatePicker({
										skin : 'whyGreen',
										minDate : '#F{$dp.$D(\'newCarDate\')}',
										maxDate : '%y-%M-%d',
										dateFmt : 'yyyy-MM-dd'
									});
								});
						$("input[name='regDate']").addClass("Wate").bind(
								"click", function() {
									WdatePicker({
										skin : 'whyGreen',
										minDate : '#F{$dp.$D(\'buyNewDate\')}',
										maxDate : '%y-%M-%d',
										dateFmt : 'yyyy-MM-dd'
									});
								});
						
						$("#licenseplateNumber").focus();
					
						 if('${buyPrice}'){
							 $("#fmtPrice").formatCurrency(); 
						 }
						 
						 $("#fmtPrice").blur(function(){
							 $("#buyPrice").val($("#fmtPrice").val());
				             $("#fmtPrice").formatCurrency();
				      	});
						
						//为inputForm注册validate函数
						$("#inputForm")
								.validate(
										{
											event : "blur",
											rules : {
												licenseplateNumber : {
													required : true,
													remote : "${ctx}/asset/car/information!findByLienNum.action?oldCarLicen="
															+ encodeURI('${licenseplateNumber}')
												},
												sindex : {
													required : true,
													remote : "${ctx}/asset/car/information!findBySindex.action?oldSindex="
															+ encodeURI('${sindex}')
												},
												engineNo : {
													required : true,
													remote : "${ctx}/asset/car/information!findByEngineNo.action?oldEngineNo="
															+ encodeURI('${engineNo}')
												},
												frameNo : {
													required : true,
													remote : "${ctx}/asset/car/information!findByFrameNo.action?oldFrameNo="
															+ encodeURI('${frameNo}')
												},
												code : {
													required : true,
													remote : "${ctx}/asset/car/information!findByCode.action?oldCode="
															+ encodeURI('${code}')
												},
												brand:"required",
												regDate:"required",
												asstState:"required",
												model:"required",
												fmtPrice : {
													required : true
												},
												productIoner : {
													maxlength : 20
												},
												contactPhone : "digits",
												driverCalls : "digits"
											},
											messages : {
												licenseplateNumber : {
													required : "必须填写车牌号！",
													remote : "当前车牌号已被添加！"
												},
												productIoner : {
													maxlength : "不得超过20个字符"
												},
												contactPhone : {
													digits : "必须输入正确的格式【纯数字】"
												},
												driverCalls : {
													digits : "必须输入正确的格式【纯数字】"
												}
											}
										});

						$("#carColor").blur(function() {
							var color = $("#carColor").val();
							var expre = /^[\u4e00-\u9fa5]{2,3}$/;
							if (!(expre.test(color))) {
								alert("请输入正确的颜色名称!");
								return false;
							}
						});
					});
</script>
</head>
<body>

<form action="${ctx }/asset/car/information!save.action" method="post"
	id="inputForm" class='yform'>
<div id="caption">
<h6>${licenseplateNumber}车辆信息</h6>
</div>
<table class="noborder">
	<tr class="type-title">
		<td colspan="4">车辆信息</td>
	</tr>
	<tr class="type-text">
		<td>车牌号</td>
		<td><input id="licenseplateNumber" name="licenseplateNumber"
			type="text" value="${licenseplateNumber}" /> <input type="hidden"
			id="id" name="id" value="${id}" /></td>
		<td>车辆名称</td>
		<td><input name="brand" value="${brand }" type="text"></input></td>
	</tr>
	<tr class="type-text">
		<td>编号</td>
		<td><input id="sindex" name="sindex"
			type="text" value="${sindex}"	 /></td>
		<td>资产编号</td>
		<td><input name="code" value="${code}" type="text"></input></td>
	</tr>
	<tr class="type-text">
		<td>厂牌型号</td>
		<td><input type="text" name="model" value="${model}" /></td>
		<td>车辆类型</td>
		<td><pt:code name="carType" category="2022" prompt="全部"
			default="${carType}"></pt:code></td>
	</tr>
		<tr class="type-text">
		<td>发动机号</td>
		<td><input type="text" name="engineNo" value="${engineNo}" /></td>
		<td>车架号</td>
		<td><input type="text" name="frameNo" value="${frameNo}" /></td>
	</tr>
	<tr class="type-select">
		<td>生产日期</td>
		<td><input id="newCarDate" type="text" name="productionDate"
			<fmt:formatDate value="${productionDate}" pattern="yyyy-MM-dd"/>  readonly="readonly" /></td>
		<td>购买日期</td>
		<td class="type-text"><input id="buyNewDate" type="text"
			name="buyDate" <fmt:formatDate value="${buyDate}" pattern="yyyy-MM-dd"/>  readonly="readonly" /></td>
	</tr>
	<tr class="type-select">
		<td>上牌日期</td>
		<td><input id="regDate" type="text" name="regDate"
			<fmt:formatDate value="${regDate}" pattern="yyyy-MM-dd"/> readonly="readonly" /></td>
		<td>车辆状态 </td>
		<td class="type-text">
		<pt:code category="2019" name="asstState" default="${asstState}" hasEmpty="false" ></pt:code>
		</td>
	</tr>
	<tr class="type-text">
		<td>颜色</td>
		<td><input type="text" id="carColor" name="carColor"
			value="${carColor }" /></td>
		<td>购买价格</td>
		<td><input type="text" id="fmtPrice" name="fmtPrice" value="${buyPrice }" />
		<input type="hidden" id="buyPrice" name="buyPrice" value="${buyPrice }" /></td>
	</tr>
	<tr class="type-text">
		<td>生产厂家</td>
		<td><input type="text" name="productIoner"
			value="${productIoner}" /></td>
		<td></td>
		<td></td>
	</tr>
	<tr class="type-title">
		<td colspan="4">供应商信息</td>
	</tr>
	<tr class="type-text">
		<td>供应商</td>
		<td><input type="text" name="supplier" value="${supplier}" /></td>
		<td>联系人</td>
		<td><input type="text" name="contactPersion"
			value="${contactPersion }" /></td>
	</tr>
	<tr class="type-text">
		<td >联系电话</td>
		<td><input type="text" name="contactPhone"
			value="${contactPhone }" /></td>
	</tr>
	<tr>
		<td>地址</td>
		<td colspan="3">
		<input name="address" value="${address}" />
		</td>
	</tr>
	<tr class="type-title">
		<td colspan="4">其他信息</td>
	</tr>
	<tr class="type-text">
		<td>驾驶员</td>
		<td><input type="text" name="driver" value="${driver}" /></td>
		<td>驾驶员电话</td>
		<td><input type="text" name="driverCalls" value="${driverCalls }"></input>
		</td>
	</tr>
	<tr class="type-text">
		<td>备注</td>
		<td colspan="3"><textarea rows="5" name="remark" cols="30">${remark}</textarea>
		</td>
	</tr>
</table>
<div class="type-button"><input type="submit" class="submit"
	value="提交" />&nbsp; <input type="button" value="返回" class="reset"
	onclick="history.back()" /></div>
</form>
</body>
</html>
